﻿#include <stdio.h>
#include "stk_dump.h"

class CAbc {
public:
	CAbc() {}
	~CAbc() {}
	int add(int a, int b) {
		STK_DATA sd;
		//get stk info
		get_cur_call_stack(&sd);

		//parse stk
		parse_1_stk(&sd);

		//show stk
		for (int i = 0; i < sd.stk_cnt; ++i) {
//			printf("%d  0x%p 0x%p 0x%p %s %s\n", sd.stk_arr[i].depth, sd.stk_arr[i].stk_top, sd.stk_arr[i].bp,
//					sd.stk_arr[i].lr, sd.stk_arr[i].func_name, sd.stk_arr[i].line_info);
            printf("%d %p\n", sd.stk_arr[i].depth, sd.stk_arr[i].lr);
		}

		//release resource
		release_1_stk(&sd);
		return a + b;
	}
};

class CXyz {
public:
	CXyz() {}
	~CXyz() {}

	void first_step() {
		fn();
		printf("hello\r\n");
	}

	void fn() {
		int a = 5;
		int b = 8;
		CAbc abc;
		int c = abc.add(a, b);
		printf("%d+%d=%d\r\n", a, b, c);
	}

private:
};

int main() {
	CXyz xyz;
	xyz.first_step();
	while(1);
	return 0;
}
